﻿#include "HelpDialog.h"
#include <windows.h>
#include <windowsx.h>
#include <QDesktopServices>
#include <QDateTime>
#include "Security\SecurityDLL.h"

HelpDialog::HelpDialog(QWidget *parent)
	:QDialog(parent)
{
	ui.setupUi(this);	
	setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
	setWindowTitle(parent->windowTitle());
		
	ui.textHelp->setOpenExternalLinks(true);

    QString text = tr("\n\n             电池检测系统软件            \n\n             BTEServer_V3.2.1            \n             版权所有（C）2021              \n             深圳市力仪科技有限公司               \n\n\n\n");
    text.replace("\\n", "\n");
    int sec;
    int ret = CheckRegTime(sec);
    if (ret == SECURITY_OK)
    {
        QString strDay = QDateTime::currentDateTime().addSecs(sec).toString("yyyy-MM-dd");
        text += tr("已注册,到期时间:") + strDay;
    }
    else
        text += tr("未注册");

    ui.textHelp->setText(text);
}

void HelpDialog::on_textHelp_anchorClicked(const QUrl & link)
{
	QDesktopServices::openUrl(link);
}